local gamelib = require "club.threecard.gamelib"
local slotlib = require "club.threecard.slotlib"
local components = slotlib.require "components"

local slot_system = slotlib.systems.slot_system
local class = gamelib.entitas.class
local Matcher = gamelib.entitas.Matcher
local GroupEvent = gamelib.entitas.GroupEvent

local discover_symbol_system = class("discover_symbol_system", slot_system)

function discover_symbol_system:get_trigger()
    return {{Matcher({components.cover_symbol_component}), GroupEvent.ADDED | GroupEvent.UPDATE}};
end

function discover_symbol_system:filter(entity)
    return entity:has(components.cover_symbol_component)
end

function discover_symbol_system:execute(entitas)
    if entitas:size() ~= 1 then
        gamelib.log.error("数据错误，结果组件不可能~=1->"..entitas:size())
        return;
    end

    entitas:foreach(function(e)
        if e:has(components.cover_symbol_component) then
            if self.ingame.cover_panel then
                self.ingame.cover_panel:SetActive(false);        
            end
        end
    end)
end

function discover_symbol_system:_finish()
    discover_symbol_system.super._finish(self);
    if self.context.machine:has(components.cover_symbol_component) then
        if self.ingame.cover_panel then
            self.ingame.cover_panel:SetActive(false);
        end
    end
end

return discover_symbol_system